package engine.colliders;

import engine.entities.Energy;
import engine.entities.Entity;
import engine.entities.Spatial;

public class Damage extends AABBCollisionResolver {

	@Override
	public void updateCollision(Entity a, Entity b) {
		Spatial spatialA = a.getSpatial();
		Spatial spatialB = b.getSpatial();
		float speedAX = spatialA.getSpeedX();
		float speedAY = spatialA.getSpeedY();
		float speedBX = spatialB.getSpeedX();
		float speedBY = spatialB.getSpeedY();
		float dXSpeed = Math.abs(speedAX) - Math.abs(speedBX);
		float dYSpeed = Math.abs(speedAY) - Math.abs(speedBY);

		float dSpeed = dXSpeed + dYSpeed;
		if (dSpeed < 0) {
			Energy energy = a.getEnergy();
			energy.add((int)dSpeed);
		}
	}

}
